package com.example.mybaisplus1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybaisplus1.entity.TUser;
import com.example.mybaisplus1.dao.TUserMapper;
import com.example.mybaisplus1.service.ITUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuyongli
 * @since 2022-12-28
 */
@Service
public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements ITUserService {

    @Override
    public IPage listByTelAndUsername(TUser user,Page page) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (StringUtils.isNotBlank(user.getTelephone())){
            queryWrapper.like("telephone",user.getTelephone());

        }
        if (StringUtils.isNotBlank(user.getUsername())){
            queryWrapper.like("username",user.getUsername());
        }

        IPage iPage = this.page(page,queryWrapper);
        return iPage;
    }
}
